#include<bits/stdc++.h>
using namespace std;
long long read(){
	long long re=0,flag=1;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')flag=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		re=re*10+c-'0';
		c=getchar();
	}
	return re*flag;
}
long long n,m,V,L,p[100010],ans1,ans2,k,ff=0;
struct node{
	long long d,v,a,zt,ztl,ztr;
}ca[100010];
bool cmp(node x,node y){
	return x.d<y.d;
}
bool cmp1(node x,node y){
	if(x.ztl==y.ztl)return x.ztr<y.ztr;
	return x.ztl<y.ztl;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	long long T=read();
	while(T--){
		ans1=0;ans2=0;k=0;n=0,m=0,L=0;ff=0;
		for(int i=1;i<=n;i++){
			ca[i].zt=0;ca[i].d=0;ca[i].v=0;ca[i].a=0;ca[i].ztl=0;ca[i].ztr=0;
		}
		memset(p,0,sizeof(p));
		ans1=0;ans2=0;
		n=read();m=read();L=read();V=read();
		for(int i=1;i<=n;i++){
			ca[i].zt=0;ca[i].d=read();ca[i].v=read();ca[i].a=read();
		}
		for(int i=1;i<=m;i++){
			p[i]=read();
		}
		sort(ca+1,ca+1+n,cmp);
		sort(p+1,p+1+m);
		int l,r,mid,rx,x,v0,rx1;
		for(int i=1;i<=n;i++){
			rx=0,rx1=0,l=1,r=m,mid=(l+r)/2;
			if(ca[i].a>0){
				while(l<=r){
					mid=(l+r)/2;
					if(p[mid]>=ca[i].d){
						v0=ca[i].v;x=p[mid]-ca[i].d;
						if(2*x*ca[i].a+v0*v0<=V*V){
							l=mid+1;
						}
						else{
							rx=mid;
							r=mid-1;
						}
					}
					else{
						l=mid+1;
					}
				}
				if(rx==0)continue;
				ca[i].zt=m-rx+1;
				ca[i].ztl=rx;ca[i].ztr=m;
				ans1++;	
			}
			if(ca[i].a==0){
				while(l<=r){
					mid=(l+r)/2;
					if(p[mid]>=ca[i].d){
						rx=mid;
						r=mid-1;
					}
					else{
						l=mid+1;
					}
				}
				if(rx==0)continue;
				if(ca[i].v<=V)continue;
				ca[i].zt=m-rx+1;
				ca[i].ztl=rx;ca[i].ztr=m;
				ans1++;
			}
			if(ca[i].a<0){
				v0=ca[i].v;
				if(v0<=V)continue;
				while(l<=r){
					mid=(l+r)/2;
					if(p[mid]>=ca[i].d){
						rx=mid;
						r=mid-1;
					}
					else{
						l=mid+1;
					}
				}
				if(rx==0)continue;
				l=1;r=m;
				while(l<=r){
					mid=(l+r)/2;
					x=p[mid]-ca[i].d;
					if(x>=0){
					if(2*x*ca[i].a+v0*v0<=V*V){
						r=mid-1;
					}
					else{
						rx1=mid;
						l=mid+1;
					}
					}
					else{
					l=mid+1;
					}
				}
				if(rx1==0)continue;
				ans1++;
				ca[i].zt=rx1-rx+1;	
				ca[i].ztl=rx;ca[i].ztr=rx1;
				
			}
		}
		cout<<ans1<<' ';
		if(ans1==0){
			cout<<m<<endl;
			continue;
		}
		else{
			k=0;ff=0;
			int mi=0;
			sort(ca+1,ca+1+n,cmp1);
			int i=1;
			while(ca[i].ztl==0)i++;
			mi=ca[i+1].ztr;
			for(;i<=n;i++){
				if(ca[i].ztl<=mi){
					if(ca[i].ztr<mi)mi=ca[i].ztr;
					continue;
				}
				else{
					if(ca[i].ztr<=mi)mi=ca[i].ztr;
					else{
						ans2++;
						mi=ca[i].ztr;
					}
				}
			}
			ans2+=1;
			cout<<m-ans2<<endl;
		}
	}
	return 0;
}
